package DAO;

import java.sql.*;

public abstract class DAO<T> {

    protected Connection connexion;

    public DAO(Connection c){
    	connexion = c;
    }
        
    protected PreparedStatement prepare(String req){
        try{
            PreparedStatement st = connexion.prepareStatement(req);
            return st;
        }catch(SQLException e){
            System.out.println("SQLException: " + e.getMessage());
            System.out.println("SQLState: " + e.getSQLState());
            System.out.println("VendorError: " + e.getErrorCode());
            return null;
        }
    }
    
    public abstract T create(T obj);
    
    public abstract ResultSet find(long id);
    
    public abstract boolean update(T obj);

    public abstract boolean delete(T obj);
}
